<?php 
require_once $_SERVER["DOCUMENT_ROOT"]."/inc/core/env.inc.php";

$return["success"] = false; 
$return["html"] = null;
$return["error"] = null;

if ($_USER->asPermission('mod_page')){
	$return["success"] = true;
	$options = '';
	$siteComponent = new Site();
	$threePages = $siteComponent->getThreePages(0, 0);
	
	foreach ($threePages as $ele) {
			
		if ($ele["id"] == $_POST["idPage"]) {
			$selected = ' selected="true" ';
		} else {
			$selected = '';
		}
			
		$padding = '&nbsp;';
		for($j=0; $j<$ele["livel"]; $j++) {
			$padding .= '&nbsp;&nbsp;';
		}
			
		$options .= '<option value="'.$ele["id"].'"'.$selected.'>'.$padding.'|_'.$_TRANSLATE->traslate($ele["name"], $_SESSION["LANGUAGE"]).'</option>';
	}
	
	$frm = file_get_contents($_SITE['path']['dir']['blocks']['containers']['admin'].'/admin-frm-page-add.tag.html');
	$frm = str_replace($_TAGS["admin-select-page-add-options"], $options, $frm);
	$frm = '<li>'.$frm.'</li>';
	
	$return["html"] = file_get_contents($_SITE['path']['dir']['blocks']['containers']['admin'].'/admin-rows.tag.html');
	$return["html"] = str_replace($_TAGS["admin-rows"], $frm, $return['html']);
}

echo '('.json_encode($return).')';
?>